<?php
/*
 * Created on 2013-2-19
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 $_POST[Sender] = '1004634672';
 
 define('IN_ECS', true);
 header("Content-Type: text/html; charset=utf-8");
 require_once "./Common/init.php";
 $cookes_file = ROOT_PATH . "/Temp/" .md5("傲娇索妮娅酱"."123456789") . ".dat";
	if (!file_exists($cookes_file)) {
		$post_fields = "username=" . URLEncode("傲娇索妮娅酱") . "&password=" . URLEncode("123456789");
		$do = new CurlUtil("http://www.acfun.tv/login.aspx");
		$do->cookie_file = $cookes_file;
		$do->post_fields = $post_fields;
		$do->header = 1;
		$do->init();
	    $do->getBody();
	}
 //$do = new CurlUtil("http://www.acfun.tv/api/member.aspx?name=mentions&pageNo=1&pageSize=10");
	$do = new CurlUtil("http://www.acfun.tv/comment_list_json.aspx?contentId=818339&currentPage=1") ;
 $do->cookie_file = $cookes_file;
 $do->init();

 $message = $do->getBody();
 echo $message;
// $a = @ json_decode($message);
// print_r($a);
 exit;
// return ;
 $c = ($a->commentList);
 $contentList = $a->contentList;
 $i=0;
 foreach($c as $key => $value) {
 	$contentId = $contentList[$i++]->aid;
 	$keys = "c".$value;
 	$ret2 = @ DB :: GetQueryResult("select * from td_acfun_alt where `keyValue`='{$keys}' ", false); //配置参数初始化
	$count = count($ret2);
	if($count!=0) {
		continue;
	}
 	$obj = $a->commentContentArr->$keys;
 	$userName = $obj->userName;
 	$content = $obj->content;
 	$p = '/\[at\]傲娇索妮娅酱\[\/at\](.*)/si';
	preg_match($p, trim($content), $m);
	if(!$m || !$m[1] || trim($m[1])=="") {
		continue;
	}
	$content = $m[1];
	$content = str_replace("[at]","",$content);
	$content = str_replace("[/at]","",$content);
	$content = strip_tags($content);
 	$quoteId = $value;
 	$qq = "261589289";
 	$flag = 0;
 	$arr = array(
 		'keyValue' => $keys ,
 		'userName' =>$userName,
 		'content' =>$content,
 		'quoteId' =>$quoteId,
 		'flag' =>$flag,
 		'qq' =>$qq,
 		'contentId'=>$contentId
 	);
 	
 	@DB :: SaveTableRow('td_acfun_alt', $arr);
 }
 
?>
